package cn.ac.cintcm.dataconverge.researchsubject.dao.impl;

import java.util.Map;

import org.apache.log4j.Logger;
import org.hibernate.Query;

import com.hs.core.page.PageParam;
import com.hs.core.page.PageQuery;
import com.hs.core.page.PageUtil;
import com.hs.core.utils.Tools;

import cn.ac.cintcm.dataconverge.dao.impl.BaseDao;
import cn.ac.cintcm.dataconverge.researchsubject.dao.IFundDao;

public class FundDao extends BaseDao implements IFundDao {

	private static Logger logger = Logger.getLogger(FundDao.class);

	public PageUtil getFundList(PageParam pageParam) {
		PageQuery pq = new PageQuery(pageParam);
		Query query = null;
		query = this.getSession().createQuery(pageParam.getSearchSql());
		Map map =pageParam.getConditionMap();
		int i = 0;
		if(map.containsKey("subjectname"))
		{     
			query.setString(i++, "%"+(String)map.get("subjectname")+"%");
		} 
		if(map.containsKey("startdate"))
		{     
			query.setDate(i++, Tools.getDateByYmdStr((String)map.get("startdate")));
		} 
		if(map.containsKey("enddate"))
		{     
			query.setDate(i++, Tools.getDateByYmdStr((String)map.get("enddate")));
		} 
		PageUtil pu = pq.getPageUtil(query);
		return pu;
	}
}
 
